package com.example.taobaounion.base;

import android.annotation.SuppressLint;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

@SuppressLint("Registered")
public class BaseActivity extends AppCompatActivity {

    protected Unbinder mUnbinder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        initContentView();

//        initTheme();

        mUnbinder = ButterKnife.bind(this);

        initVariable();
        initFragment();
        initPresenter();

        initListener();
        initData();

        initView();
    }

    /**
     * 一个黑白的全局主题
     */
    private void initTheme() {
        // Create a ColorMatrix(颜色矩阵）
        ColorMatrix lColorMatrix = new ColorMatrix();
        // 设置颜色矩阵饱和度为0
        lColorMatrix.setSaturation(0);

        Paint lPaint = new Paint();

        // 使用饱和度为0的颜色矩阵 创建一个黑白的画笔
        lPaint.setColorFilter(new ColorMatrixColorFilter(lColorMatrix));

        View lContentContainer = getWindow().getDecorView();

        lContentContainer.setLayerType(View.LAYER_TYPE_SOFTWARE, lPaint);

        // 将这个黑白的画笔给布局的父级容器
        lContentContainer.setLayerPaint(lPaint);
    }

    protected void initFragment() {

    }

    protected void initView() {

    }

    protected void initData() {

    }

    protected void initListener() {

    }

    protected void initPresenter() {

    }

    protected void initVariable() {

    }

    protected void initContentView() {

    }
}
